/**
 * 
 * @author maxd
 * @date 2019.8.1
 */
module.exports = {
	
	logout() {
		this.remove("token");
		this.remove("isRealName");
	},
	loginClear() {
		this.remove("token");
		
	},
	showLoading(title) {
		uni.showLoading({
			title: title
		});
	},
	remove(value){
		uni.removeStorageSync(value)
	},
	showToast(title, duration=1500, mask=false, icon='none') {
		//统一提示方便全局修改
		if(Boolean(title) === false){
			return;
		}
		uni.showToast({
			title,
			duration,
			mask,
			icon
		});
	},
	setJson: function(key, value) {
		let jsonString = JSON.stringify(value);
		try {
			uni.setStorageSync(key, jsonString);
		} catch (e) {
			// error
		}
	},
	setData: function(key, value) {
		try {
			uni.setStorageSync(key, value);
		} catch (e) {
			// error
		}
	},
	getData: function(key) {
		try {
			const value = uni.getStorageSync(key);
			if (value) {
				return value;
			}
		} catch (e) {
			// error
		}

	},
	getJson: function(key) {
		try {
			const value = uni.getStorageSync(key);
			if (value) {
				return JSON.parse(value);
			}
		} catch (e) {
			// error
		}

	},
	clear: function() {
		uni.clearStorage();
	},

};
